<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="./favicon.ico">
    <!-- <link rel="stylesheet" href="./favicon.ico"> -->
    <title>bilibili</title>
    <style>
        html {
            height: 5000px;
        }

        .warp {
            position: fixed;
            right: 10px;
            top: 20px;
        }
    </style>
</head>

<body>
    <div class="warp">
        <button id="scrollBy">scrollBy</button>
        <button id="scrollTo">scrollTo</button>
    </div>

</body>
<script>
    var scrollByBtn = document.getElementById("scrollBy");
    var scrollToBtn = document.getElementById("scrollTo");
    // console.log(window);
    // // 所有页面加载完后再执行里面的内容
    // window.onload = function () {

    // }
    // // 滚动条滚动时触发
    // window.onscroll = function () {

    // }

    // 窗口改变时触发
    // onresize = function () {
    //     console.log(innerWidth, innerHeight);
    //     console.log(outerWidth, outerHeight);
    // }

    // scrollByBtn.onclick = function () {
    //     scrollBy(0, 300);
    // }

    // scrollToBtn.onclick = function () {
    //     scrollTo(0, 3000);
    // }

    // document.documentElement  对html直接访问
    // document.body  对body直接访问

    // document.title 获取和设置标题内容
    // <link rel="shortcut icon" href="./favicon.ico"> 设置网页标题图标

    function dateFormat(replace, date) {
        var date = day == undefined ? new Date() : new Date(date);
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        var hour = date.getHours();
        var minute = date.getMinutes();
        var second = date.getSeconds();
        return replace.replace("YY", year).replace("MM", month).replace("DD", day).replace("hh", hour).replace("mm", minute).replace("ss", second);
    }
    var replace = "YY/MM/DD hh:mm:ss";
    document.title = dateFormat(replace);
    var timer = setInterval(function () {
        document.title = dateFormat(replace);
    }, 1000);
</script>

</html>